//
//  UILable+ZZExtension.swift
//  MeunDemo
//
//  Created by hfzhangzhang on 2018/3/20.
//  Copyright © 2018年 hfzhangzhang. All rights reserved.
//

import UIKit
//
extension UILabel{
    
    func customSizeToFit()  {
       self.customSizeToFit(lineSpacing: 6)
    }
    func customSizeToFit(lineSpacing:CGFloat) -> () {
        if self.text != nil {
            let attributedString:NSMutableAttributedString = NSMutableAttributedString(string: self.text!)
            let paragraphStyle:NSMutableParagraphStyle = NSMutableParagraphStyle()
            paragraphStyle.lineSpacing = lineSpacing //大小调整
            attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, self.text!.count))
            self.attributedText = attributedString
            self.sizeToFit()
        }
    }  
}

